Skip to content

Make time-stepping mode a SimulationMetaData type parameter#175

Open
AhmedSalih3d wants to merge 4 commits into
BeforeLidDrivenCavityExamplefrom
codex/change-timesteppingmode-to-type-parameter
Open

Make time-stepping mode a SimulationMetaData type parameter#175
AhmedSalih3d wants to merge 4 commits into
BeforeLidDrivenCavityExamplefrom
codex/change-timesteppingmode-to-type-parameter

Conversation

@AhmedSalih3d

Copy link
Copy Markdown
Owner

Motivation

  • Avoid runtime abstract-field inference loss from storing TimeSteppingMode as an abstract field so compiled inner loops can reason about the time-stepping strategy at compile time.
  • Allow the time-stepping mode to be selected conveniently via existing short SimulationMetaData constructors while ensuring the concrete mode is available to performance-sensitive code paths.

Description

  • Add a TMode<:TimeSteppingMode type parameter to SimulationMetaData and replace the runtime TimeSteppingMode field with a concrete TimeSteppingMode::Type{TMode} stored value in src/SimulationMetaDataConfiguration.jl.
  • Provide helpers (_time_stepping_type, _metadata_kwargs_without_time_stepping_mode) and a SimulationMetaData{...}(; kwargs...) constructor that accepts TimeSteppingMode as either a type or instance and yields a SimulationMetaData specialized on the chosen TMode.
  • Update the simulation entry points in src/SPHCellList.jl to derive TimeSteppingType = typeof(SimTimeStepping) in RunSimulation, pass that Type into SimulationLoop, and branch on the compile-time TMode (if TMode <: SingleNeighborTimeStepping / if TMode <: SymplecticTimeStepping) instead of reading an abstract field.
  • Preserve existing short constructors for other metadata combinations and keep the default mode as SingleNeighborTimeStepping when not specified.

Testing

  • Ran julia --project=. -e 'using SPHExample; meta=SimulationMetaData{2,Float64}(SimulationName="x", SaveLocation=".", TimeSteppingMode=SymplecticTimeStepping()); @show typeof(meta); @show meta.TimeSteppingMode; meta2=SimulationMetaData{2,Float64}(SimulationName="x", SaveLocation=".", TimeSteppingMode=SingleNeighborTimeStepping); @show typeof(meta2);' which succeeded and showed the metadata specialized on the selected time-stepping types.
  • Ran the package test suite with julia --project=. -e 'using Pkg; Pkg.test()' which precompiled successfully but the time stepping test errored due to an existing Δt method-signature mismatch (test calls Δt with five arguments while only a three-argument method exists), so the test run did not fully pass.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant